<?php defined('SYSPATH') or die();?>

    <div class="page out" id="countInvite">
        <div class="header_top">
            <a class="back-link-icon" href="javascript:;" data-rel="back"></a>
            <h1 class="page-title-bar">累计邀请</h1>
        </div>
        <!-- 公用顶部 -->
        <div class="page-content">
            <div class="tip-search-wrap">
                <form name="" id="search-form" action="javascript:;" class="fenxiao_subfx_search_fm">
                    <div class="search-bar">

                        <input type="search" name="" id="subfx_keyword"  class="search-text" placeholder="请输入分销商名称进行搜索" />
                        <i class="search-icon"></i>
                    </div>
                </form>
            </div>
            <div class="search-bg-layer"></div>
            <div class="search-filter-bar">
                <div class="search-tab-item col-2">
                    <strong class="tab-name">筛选</strong>
                    <ul class="item-list" id="subfx_group">
                        <li>全部好友</li>
                        <li value="1">我的直接好友</li>
                        <li value="2">我的二级好友</li>
                        {if $level_num==3}
                        <li value="3">我的三级好友</li>
                        {/if}
                    </ul>
                </div>
                <div class="search-tab-item col-2">
                    <strong class="tab-name">排序</strong>
                    <ul class="item-list" id="subfx_order">
                        <li value="1">收益由高到低</li>
                        <li value="2">收益由低到高</li>
                        <li value="3">注册时间倒序排列</li>
                        <li value="4">分销商等级倒序排列</li>
                    </ul>
                </div>
            </div>
            <div class="search-list-wrap">
                <ul class="search-invite-list" id="subfx_list">

                </ul>
                <!-- 累计列表 -->
                <div class="null-order-box hide">
                    <div class="info">
                        <i class="icon"></i>
                        <p class="txt">您还没有下级，马上<a class="link" href="{$cmsurl}fenxiao/invite">邀请好友</a>成为下级</p>
                    </div>
                </div>
                <div class="no-info-bar" id="fenxiao_subfx_no_more" style="display: none;">没有更多结果了！</div>
                <!-- 空订单 -->
            </div>
        </div>
    </div>
    <script>


        (function()
        {
            var SITEURL = "{URL::site()}";
            var CURRENCY_SYMBOL="{Currency_Tool::symbol()}";
            var gbl_page=1;
            var gbl_is_loading=false;

            $("#countInvite .search-tab-item .tab-name").on("click", function () {
                $(this).parent(".search-tab-item").addClass("cur-tab-item").siblings().removeClass("cur-tab-item");
                $("#countInvite .search-list-wrap").css("overflow", "hidden");
                $("#countInvite .search-bg-layer").show();
            });

            $("#countInvite .search-tab-item .item-list>li").on("click", function () {
                $(this).addClass("on").siblings().removeClass("on");
                $(this).parents(".search-tab-item").removeClass("cur-tab-item");
                $("#countInvite .search-list-wrap").css("overflow", "auto");
                $("#countInvite .search-bg-layer").hide();
                gbl_page=1;
                get_subfx(1);
            });

            $("#countInvite .search-bg-layer").on("click", function () {
                $(this).hide();
                $("#countInvite .search-tab-item").removeClass("cur-tab-item");
                $("#countInvite .search-list-wrap").css("overflow", "auto");
            })

            $("#countInvite .search-list-wrap").scroll(function(){
                var scroll_top=$('#countInvite .search-list-wrap').scrollTop();
                if(scroll_top+3>=($("#countInvite .search-list-wrap")[0].scrollHeight - $('#countInvite .search-list-wrap').outerHeight()))
                {
                    if(gbl_is_loading==false)
                    {
                        get_subfx(gbl_page+1);
                    }
                }
            });


            //搜索按钮
            $("#countInvite .search-icon").click(function(){
                gbl_page=1;
                get_subfx(1);
            })

            $(".fenxiao_subfx_search_fm").submit(function(){
                get_subfx(1);
            });

            get_subfx(1);

            //获取产品列表
            function get_subfx(page)
            {
                gbl_is_loading=true;

                var group=$("#subfx_group li.on").attr('value');
                var keyword=$("#subfx_keyword").val();
                var order=$("#subfx_order li.on").attr('value');

                var params={
                    group:group,
                    keyword:keyword,
                    order:order,
                    page:page
                }
                $.ajax({
                    url:SITEURL+'fenxiao/ajax_get_subfx',
                    type:'POST', //GET
                    data:params,
                    dataType:'json',
                    success:function(data,textStatus,jqXHR){
                        gbl_is_loading=false;
                        if(data.status)
                        {
                            var html='';

                            for(var i in data.list)
                            {
                                var row=data.list[i];
                                var friend_str = row['sub_level']==1?'直接好友':'间接好友';
                                html+='<li><div class="hd">'+
                            '<img src="'+row['litpic']+'" />'+
                            '<p class="name">'+row['nickname']+'</p>'+
                            '<p class="num">'+row['account']+'</p>'+
                            '</div>'+
                            '<div class="bd">'+
                            '<div class="txt">我的收益<span class="c-f60">'+CURRENCY_SYMBOL+row['total']+'</span></div>'+
                            '<div class="info">'+
                            '<div class="label">'+
                            '<i class="icon"></i>'+
                            '<span class="sm">'+friend_str+'<br />'+row['fxrank_name']+'</span>'+
                            '</div>'+
                            '<div class="label">'+
                            '<i class="icon"></i>'+
                            '<span class="sm">拥有<br />'+row['sub_num']+'个好友</span>'+
                            '</div>'+
                            '<div class="label">'+
                            '<i class="icon"></i>'+
                            '<span class="sm">'+row['fxjointime']+'<br />成为分销商</span>'+
                            '</div> </div> </div> </li>';

                            }
                            if(page==1)
                            {
                                $("#subfx_list").children().remove();
                            }
                            $("#subfx_list").append(html);

                            if(html!='')
                            {
                                gbl_page = page;
                            }
                        }

                        if(data.list.length<10)
                        {
                            $("#fenxiao_subfx_no_more").show();
                        }
                        if($("#subfx_list li").length==0)
                        {
                            $("#countInvite .null-order-box").show();
                            $("#fenxiao_subfx_no_more").hide();
                        }
                        else
                        {
                            $("#countInvite .null-order-box").hide();
                        }

                    }
                })


            }





        })();

    </script>

